﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Dashboard.Expense.Business;

namespace Dashboard.Expense
{
    public partial class FormAddApplicationType : Form
    {
        public FormAddApplicationType()
        {
            InitializeComponent();
        }

        private void toolStripButtonSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.textBoxCode.Text.Trim()))
            {
                MessageBox.Show(this, "Please input the Type Code field.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.textBoxCode.Focus();
                return;
            }

            try
            {
                string code = this.textBoxCode.Text.Trim();
                string description = this.textBoxDescription.Text.Trim();

                Exp_ExpenseType eet = new Exp_ExpenseType();
                eet.AddApplicationType(code, description);

                MessageBox.Show(this, "Save successfully!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void toolStripButtonCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.Close();
        }
    }
}
